package com.example.liwushuo.adapter;

import java.util.List;

import com.example.liwushuo.BaseApp;
import com.example.liwushuo.HorzontalScrollActivity;
import com.example.liwushuo.R;
import com.example.liwushuo.bean.Collections;
import com.lidroid.xutils.BitmapUtils;

import android.content.Context;
import android.content.Intent;

import android.support.v4.content.LocalBroadcastManager;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.Toast;

public class HorizontalListViewAdapter extends BaseAdapter {

	private List<Collections> list;
	private Context con;
	private BitmapUtils bitmapUtils;
	private LayoutInflater mInflater;
	public HorizontalListViewAdapter(Context con, List<Collections> list) {
		this.con = con;
		mInflater = LayoutInflater.from(con);
		this.list = list;
		bitmapUtils = new BitmapUtils(con);
	}

	@Override
	public int getCount() {
		return list.size();
	}

	

	@Override
	public Object getItem(int position) {
		return list != null && list.size() > 0 ? list.get(position) : 0;
	}

	

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder vh = null;
		if (convertView == null) {
			convertView = mInflater.inflate(R.layout.horizontallistview_item,
					null);
			vh = new ViewHolder();
			vh.im = (ImageView) convertView.findViewById(R.id.iv_pic);

			convertView.setTag(vh);
		} else {
			vh = (ViewHolder) convertView.getTag();
		}
		Log.i("list", "--->>>>" + list.toString());

		bitmapUtils.display(vh.im, list.get(position).getBanner_image_url());

		return convertView;
	}
	private static class ViewHolder {

		private ImageView im;
	}
}